package com.atm.atmsys.Mapper.UserMapper;

import com.atm.atmsys.dto.UserPageDTO;
import com.atm.atmsys.entity.UserInfo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    // 根据用户名和密码查询用户信息
    @Select("select * from atm_database.user_info where user_name=#{userName} and user_password=#{userPassword}")
    UserInfo getByUserNameAndPassword(UserInfo userInfo);

    // 添加用户信息
    @Select("insert into atm_database.user_info (identification,user_name, user_password) values (#{identification},#{userName}, #{userPassword})")
    void addUser(UserInfo userInfo);

    @Delete("delete from atm_database.user_info where identification = #{identification}")
    void deleteUser(String identification);

    // 更新用户信息
    void updateUser(UserInfo userInfo);

    // 分页查询用户信息
    Page<UserInfo> pageQuery(UserPageDTO userPageDTO);

    // 根据用户ID查询用户信息
    @Select("select * from atm_database.user_info where user_id = #{id}")
    UserInfo getById(int id);

    // 根据身份证号查询用户信息
    @Select("select * from atm_database.user_info where identification = #{identification}")
    UserInfo getBySF(String identification);

    // 根据身份证号查询用户信息
    @Select("select * from atm_database.user_info where identification = #{identification}")
    UserInfo getByIdentification(String identification);


    @Select("select * from atm_database.user_info where user_name = #{userName}")
    UserInfo getByName(String userName);
}
